import request from "@/utils/request";
import { getToken, getUserId, getSiteId } from "@/utils/auth";
import dayjs from "dayjs";

// 获取订单列表
export function orderListApi(params = {}) {
  return request({
    url: "/OrderV2/GetOrderList",
    method: "get",
    params: {
      AccessToken: getToken(),
      SiteId: getSiteId(),
      KeyStr: "",
      BeginDate:
        params.BeginDate ||
        dayjs(new Date()).startOf("month").format("YYYY-MM-DD"),
      EndDate:
        params.EndDate || dayjs(new Date()).endOf("month").format("YYYY-MM-DD"),
      OrderStatus: "",
      PageIndex: params.PageIndex || 1,
      PageSize: params.PageSize || 10,
    },
  });
}

// 获取订单列表
export function orderInfoApi(OrderId) {
  return request({
    url: "/OrderV2/GetOrderInfo",
    method: "get",
    params: {
      AccessToken: getToken(),
      SiteId: getSiteId(),
      OrderId,
    },
  });
}

// 增加留言附图
export function msgAddApi(params = { OrderId: '', ProduceId: '', Remark: ''}) {
  return request({
    url: "/MessageAddV3/Post",
    method: "post",
    data: {
      AccessToken: getToken(),
      SiteId: getSiteId(),
      UserId: getUserId(),
      OrderId: params.OrderId,
      ProduceId: params.ProduceId || 0,
      RecvIds: params.RecvIds,
      RecvNames: params.RecvNames,
      AttatchUrl: params.AttatchUrl,
      Remark: params.Remark || '',
    },
  });
}
// 删除留言附图
export function msgDeleteApi(MsgId) {
  return request({
    url: "/MessageDeleteV3/Post",
    method: "post",
    params: {
      AccessToken: getToken(),
      SiteId: getSiteId(),
      UserId: getUserId(),
      MsgId: MsgId,
    },
  });
}